﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ICSharpCode.TextEditor.Document;

namespace NetJsWire.Design.Editors
{
    public partial class ScriptEditorForm : Form
    {
        public ScriptEditorForm()
        {
            InitializeComponent();
            //EditorPanel.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy( "JavaScript" );
        }

        private void Button1Click( object sender, EventArgs e )
        {
            _editorText = window11.textEditor.Text;
            DialogResult = DialogResult.OK;
            Close();
        }

        private string _editorText;
        public string EditorText
        {
            get
            {
                if ( _editorText == "" )
                    _editorText = null;
                return _editorText;
            }
            set
            {
                _editorText = value;
                window11.textEditor.Text = value;
            }
        }

        private void ScriptEditorFormKeyUp( object sender, KeyEventArgs e )
        {
            if ( e.Control && e.KeyCode == Keys.Enter )
            {
                Button1Click( null, EventArgs.Empty );
            }
            if ( e.KeyCode == Keys.Escape )
            {
                Close();
            }
        }
    }
}
